{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Resnet_block_architecture.ipynb",
      "provenance": [],
      "authorship_tag": "ABX9TyOTLHszFiFWrGkTp/f0kcnn",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/PacktPublishing/Modern-Computer-Vision-with-PyTorch/blob/master/Chapter05/Resnet_block_architecture.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "cuS9OIFRPtEW"
      },
      "source": [
        "import torch\n",
        "from torch import nn"
      ],
      "execution_count": 1,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "S339gpWBP06u"
      },
      "source": [
        "class ResLayer(nn.Module):\n",
        "     def __init__(self,ni,no,kernel_size,stride=1):\n",
        "        super(ResLayer, self).__init__()\n",
        "        padding = kernel_size - 2\n",
        "        self.conv = nn.Sequential(\n",
        "            nn.Conv2d(ni, no, kernel_size, stride, \n",
        "                      padding=padding),\n",
        "            nn.ReLU()\n",
        "        )\n",
        "\n",
        "    def forward(self, x):\n",
        "        return self.conv(x) + x\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}